﻿using System;
using System.Net;
using System.Collections.Generic;
using System.ComponentModel;
using System.Xml.Serialization;

namespace TileDownLoader.Elevation
{
	#region gpx
		
	public partial class gpx : System.ComponentModel.INotifyPropertyChanged
	{

		private List<wpt> wptField;

		private List<trk> trkField;

		private string versionField;

		private string creatorField;

		public gpx()
		{
			this.trkField = new List<trk>();
			this.wptField = new List<wpt>();
			this.versionField = "1.1";
			this.creatorField = "Home Brew";
		}

		[XmlElement]
		public List<wpt> wpt
		{
			get
			{
				return this.wptField;
			}
			set
			{
				if ((this.wptField != null))
				{
					if ((wptField.Equals(value) != true))
					{
						this.wptField = value;
						this.OnPropertyChanged("wpt");
					}
				}
				else
				{
					this.wptField = value;
					this.OnPropertyChanged("wpt");
				}
			}
		}
		[XmlElement]
		public List<trk> trk
		{
			get
			{
				return this.trkField;
			}
			set
			{
				if ((this.trkField != null))
				{
					if ((trkField.Equals(value) != true))
					{
						this.trkField = value;
						this.OnPropertyChanged("trk");
					}
				}
				else
				{
					this.trkField = value;
					this.OnPropertyChanged("trk");
				}
			}
		}
		[XmlAttribute]
		public string version
		{
			get
			{
				return this.versionField;
			}
			set
			{
				if ((this.versionField != null))
				{
					if ((versionField.Equals(value) != true))
					{
						this.versionField = value;
						this.OnPropertyChanged("version");
					}
				}
				else
				{
					this.versionField = value;
					this.OnPropertyChanged("version");
				}
			}
		}
		[XmlAttribute]
		public string creator
		{
			get
			{
				return this.creatorField;
			}
			set
			{
				if ((this.creatorField != null))
				{
					if ((creatorField.Equals(value) != true))
					{
						this.creatorField = value;
						this.OnPropertyChanged("creator");
					}
				}
				else
				{
					this.creatorField = value;
					this.OnPropertyChanged("creator");
				}
			}
		}

		public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;

		public virtual void OnPropertyChanged(string info)
		{
			PropertyChangedEventHandler handler = PropertyChanged;
			if (handler != null)
			{
				handler(this, new PropertyChangedEventArgs(info));
			}
		}
	} 
	#endregion

	#region wpt
	
	public partial class wpt : System.ComponentModel.INotifyPropertyChanged
	{

		private string eleField = null;

		private System.DateTime timeField;

		private string nameField = null;

		private string cmtField = null;

		private string descField = null;

		private string symField = null;

		private string latField = null;

		private string lonField = null;

		public wpt()
		{
		}

        [XmlIgnore]
        public string Description
        {
            get
            {
                string retVal = null;

                if (!String.IsNullOrWhiteSpace(this.descField))
                {
                    retVal = this.descField;
                }
                else if (!String.IsNullOrWhiteSpace(this.cmtField))
                {
                    retVal = this.cmtField;
                }
                return retVal;
            }
            set
            {
                this.cmtField = value;
                this.descField = value;
            }
        }
		 
		public string ele
		{
			get
			{
				return this.eleField;
			}
			set
			{
				if ((this.eleField != null))
				{
					if ((eleField.Equals(value) != true))
					{
						this.eleField = value;
						this.OnPropertyChanged("ele");
					}
				}
				else
				{
					this.eleField = value;
					this.OnPropertyChanged("ele");
				}
			}
		}
	   
		public System.DateTime time
		{
			get
			{
				return this.timeField;
			}
			set
			{
				if ((timeField.Equals(value) != true))
				{
					this.timeField = value;
					this.OnPropertyChanged("time");
				}
			}
		}
	   
		public string name
		{
			get
			{
				return this.nameField;
			}
			set
			{
				if ((this.nameField != null))
				{
					if ((nameField.Equals(value) != true))
					{
						this.nameField = value;
						this.OnPropertyChanged("name");
					}
				}
				else
				{
					this.nameField = value;
					this.OnPropertyChanged("name");
				}
			}
		}
		 
		public string cmt
		{
			get
			{
				return this.cmtField;
			}
			set
			{
				if ((this.cmtField != null))
				{
					if ((cmtField.Equals(value) != true))
					{
						this.cmtField = value;
						this.OnPropertyChanged("cmt");
					}
				}
				else
				{
					this.cmtField = value;
					this.OnPropertyChanged("cmt");
				}
			}
		}
		 
		public string desc
		{
			get
			{
				return this.descField;
			}
			set
			{
				if ((this.descField != null))
				{
					if ((descField.Equals(value) != true))
					{
						this.descField = value;
						this.OnPropertyChanged("desc");
					}
				}
				else
				{
					this.descField = value;
					this.OnPropertyChanged("desc");
				}
			}
		}
		 
		public string sym
		{
			get
			{
				return this.symField;
			}
			set
			{
				if ((this.symField != null))
				{
					if ((symField.Equals(value) != true))
					{
						this.symField = value;
						this.OnPropertyChanged("sym");
					}
				}
				else
				{
					this.symField = value;
					this.OnPropertyChanged("sym");
				}
			}
		}
		[XmlAttribute]
		public string lat
		{
			get
			{
				return this.latField;
			}
			set
			{
				if ((this.latField != null))
				{
					if ((latField.Equals(value) != true))
					{
						this.latField = value;
						this.OnPropertyChanged("lat");
					}
				}
				else
				{
					this.latField = value;
					this.OnPropertyChanged("lat");
				}
			}
		}
		[XmlAttribute]
		public string lon
		{
			get
			{
				return this.lonField;
			}
			set
			{
				if ((this.lonField != null))
				{
					if ((lonField.Equals(value) != true))
					{
						this.lonField = value;
						this.OnPropertyChanged("lon");
					}
				}
				else
				{
					this.lonField = value;
					this.OnPropertyChanged("lon");
				}
			}
		}

		public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;

		public virtual void OnPropertyChanged(string info)
		{
			PropertyChangedEventHandler handler = PropertyChanged;
			if (handler != null)
			{
				handler(this, new PropertyChangedEventArgs(info));
			}
		}
	} 
	#endregion

	#region trkpt
   
	public partial class trkpt : System.ComponentModel.INotifyPropertyChanged
	{

		private string eleField = null;

		private System.DateTime timeField;

		private string latField = null;

		private string lonField = null;

		public trkpt()
		{
		}

        [XmlIgnore]
        public double Elevation
        {
            get
            {
                double retVal;

                if (!Double.TryParse(this.eleField, out retVal))
                {
                    retVal = 0.0;
                }
                return retVal;
            }
        }

		public string ele
		{
			get
			{
				return this.eleField;
			}
			set
			{
				if ((this.eleField != null))
				{
					if ((eleField.Equals(value) != true))
					{
						this.eleField = value;
						this.OnPropertyChanged("ele");
					}
				}
				else
				{
					this.eleField = value;
					this.OnPropertyChanged("ele");
				}
			}
		}
	   
		public System.DateTime time
		{
			get
			{
				return this.timeField;
			}
			set
			{
				if ((timeField.Equals(value) != true))
				{
					this.timeField = value;
					this.OnPropertyChanged("time");
				}
			}
		}
		
		[XmlAttribute]
		public string lat
		{
			get
			{
				return this.latField;
			}
			set
			{
				if ((this.latField != null))
				{
					if ((latField.Equals(value) != true))
					{
						this.latField = value;
						this.OnPropertyChanged("lat");
					}
				}
				else
				{
					this.latField = value;
					this.OnPropertyChanged("lat");
				}
			}
		}
		[XmlAttribute]
		public string lon
		{
			get
			{
				return this.lonField;
			}
			set
			{
				if ((this.lonField != null))
				{
					if ((lonField.Equals(value) != true))
					{
						this.lonField = value;
						this.OnPropertyChanged("lon");
					}
				}
				else
				{
					this.lonField = value;
					this.OnPropertyChanged("lon");
				}
			}
		}

		public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;

		public virtual void OnPropertyChanged(string info)
		{
			PropertyChangedEventHandler handler = PropertyChanged;
			if (handler != null)
			{
				handler(this, new PropertyChangedEventArgs(info));
			}
		}
	}

  
	#endregion   
		
	#region trk
		
	public partial class trk : System.ComponentModel.INotifyPropertyChanged
	{

		private string nameField = null;

		private List<trkpt> trksegField;

		public trk()
		{
			trksegField = new List<trkpt>();
		}

		public string name
		{
			get
			{
				return this.nameField;
			}
			set
			{
				if ((this.nameField != null))
				{
					if ((nameField.Equals(value) != true))
					{
						this.nameField = value;
						this.OnPropertyChanged("name");
					}
				}
				else
				{
					this.nameField = value;
					this.OnPropertyChanged("name");
				}
			}
		}
	   
		public List<trkpt> trkseg
		{
			get
			{
				return this.trksegField;
			}
			set
			{
				if ((this.trksegField != null))
				{
					if ((trksegField.Equals(value) != true))
					{
						this.trksegField = value;
						this.OnPropertyChanged("trkseg");
					}
				}
				else
				{
					this.trksegField = value;
					this.OnPropertyChanged("trkseg");
				}
			}
		}

		public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;

		public virtual void OnPropertyChanged(string info)
		{
			PropertyChangedEventHandler handler = PropertyChanged;
			if (handler != null)
			{
				handler(this, new PropertyChangedEventArgs(info));
			}
		}
	}

	#endregion

	#region rte
	public partial class rte : System.ComponentModel.INotifyPropertyChanged
	{

		private string nameField = null;

		private string cmtField = null;

		private string descField = null;

		private List<wpt> rteptField;

		public rte()
		{
			this.rteptField = new List<wpt>();
		}

		public string name
		{
			get
			{
				return this.nameField;
			}
			set
			{
				if ((this.nameField != null))
				{
					if ((nameField.Equals(value) != true))
					{
						this.nameField = value;
						this.OnPropertyChanged("name");
					}
				}
				else
				{
					this.nameField = value;
					this.OnPropertyChanged("name");
				}
			}
		}

		public string cmt
		{
			get
			{
				return this.cmtField;
			}
			set
			{
				if ((this.cmtField != null))
				{
					if ((cmtField.Equals(value) != true))
					{
						this.cmtField = value;
						this.OnPropertyChanged("cmt");
					}
				}
				else
				{
					this.cmtField = value;
					this.OnPropertyChanged("cmt");
				}
			}
		}

		public string desc
		{
			get
			{
				return this.descField;
			}
			set
			{
				if ((this.descField != null))
				{
					if ((descField.Equals(value) != true))
					{
						this.descField = value;
						this.OnPropertyChanged("desc");
					}
				}
				else
				{
					this.descField = value;
					this.OnPropertyChanged("desc");
				}
			}
		}


		public List<wpt> rtept
		{
			get
			{
				return this.rteptField;
			}
			set
			{
				if ((this.rteptField != null))
				{
					if ((rteptField.Equals(value) != true))
					{
						this.rteptField = value;
						this.OnPropertyChanged("rtept");
					}
				}
				else
				{
					this.rteptField = value;
					this.OnPropertyChanged("rtept");
				}
			}
		}

		public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;

		public virtual void OnPropertyChanged(string info)
		{
			PropertyChangedEventHandler handler = PropertyChanged;
			if (handler != null)
			{
				handler(this, new PropertyChangedEventArgs(info));
			}
		}
	}  
	#endregion
	
}
